package swnxb.小组合作;

/**
 * Created by V5470-I5 on 2016/6/19.
 */
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import swnxb.小组合作.初设计.VoteOption;

public class DeleteVoteAction extends ActionSupport{
    private int voteID;

    public int getVoteID() {
        return voteID;
    }

    public void setVoteID(int voteID) {
        this.voteID = voteID;
    }

    public String execute() throws Exception {
        VoteDAO voteDAO = VoteDAOFactory.getVoteDAOInstance();
        VoteOptionDAO voteOptionDAO = VoteOptionDAOFactory
                .getVoteOptionDAOInstance();
                List<VoteOption> voteOptions = voteOptionDAO.findVoteOptionByVoteID(voteID);

        for(VoteOption voteOption : voteOptions) {
            voteOptionDAO.deleteVoteOption(voteOption.getVoteOptionID());
        }

        voteDAO.deleteVote(voteID);
        return this.SUCCESS;
    }
}
